#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>

int main()
{
	pid_t pid = 0;

  for(int i = 0;i < 10;i++)
  {
	pid = fork();
	if(pid == 0)
	{
		int i = 0;
		while(i < 5)
		{
			printf("pid = %d  %d\n",getpid(),getppid());
			sleep(1);
			i = i + 1;
		}
		exit(0);
	}
	else if(pid < 0)
	{
		printf("fork error\n");
		exit(-1);
	}
 }

  printf("father:%d\n",getpid());

  for(int i = 0;i < 10;i++)
  {
	  wait(NULL);
  }



	return 0;
}
